import java.applet.*;
import java.awt.*;

public class LightsChange extends Applet {
	LightsCanvas square;
	TextSlideL rxField,bxField, gxField;  
	TextSlideLv ryField, byField, gyField;  
	double minVal = 0.0, maxVal = 200.0;  

	public void init() {
		this.setLayout(new BorderLayout(15,15));
		Panel p = new Panel();
		p.setLayout(new GridLayout(3,1,0,4));
		rxField = new TextSlideL(this,"Rxposition",minVal,maxVal);
		p.add(rxField);
		gxField = new TextSlideL(this,"Gxposition",minVal,maxVal);
		p.add(gxField);
		bxField = new TextSlideL(this,"Bxposition",minVal,maxVal);
		p.add(bxField);
		add("South",p);
		Panel q = new Panel();
		q.setLayout(new GridLayout(1,3,0,4));
 		ryField = new TextSlideLv(this,"ryposition:",minVal,maxVal);
		q.add(ryField);
 		gyField = new TextSlideLv(this,"gyposition:",minVal,maxVal);
		q.add(gyField);
 		byField = new TextSlideLv(this,"byposition:",minVal,maxVal);
		q.add(byField);
		add("East",q);
		square = new LightsCanvas();
		this.add("Center",square);
		rxField.setValue(0.0);
		ryField.setValue(0.0);
		gxField.setValue(0.0);
		gyField.setValue(200.0);
		bxField.setValue(200.0);
		byField.setValue(0.0);
		validate();
	}

	public void start() { 
		square.enable();
	}

	public void stop() { 
		square.disable();
	}

	public void changeParam(TextSlideL which) {
		if (which == rxField) {
			square.setRXloc(rxField.getValue());
	        }
		else if (which == gxField) {
			square.setGXloc(gxField.getValue());
	        }
		else if (which == bxField) {
			square.setBXloc(bxField.getValue());
	        }
        }
 
	public void changeParam(TextSlideLv which) {
	        if (which == ryField) {
			square.setRYloc(ryField.getValue());
		} 
	        else if (which == gyField) {
			square.setGYloc(gyField.getValue());
		} 
	        else if (which == byField) {
			square.setBYloc(byField.getValue());
		} 
	}

	public void paint(Graphics g) {
		;
	}

	// Keep a main around in case we want to debug without an html page.
	// This could be greatly improved or deleted.  Either is appropriate.ff
	public static void main(String args[]) {
		Applet applet = new LightsChange();
		Frame f = new Frame("LightsChange");
		f.add("Center",applet);
		applet.init();
		applet.start();
	}

}
